const fs = require("fs");
const path = require("path");

const navs = fs.readdirSync(path.resolve(__dirname, "../"));
const sidebar = {};
navs.filter(path => !/^\.|.md$/.test(path)).forEach(nav => {
  sidebar[`/${nav}/`] = [""];
  const files = fs.readdirSync(path.resolve(__dirname, "../", nav));
  files.filter(file => !/^README|image/.test(file)).forEach(file => {
    sidebar[`/${nav}/`].push(file.split(".")[0]);
  })
});

module.exports = {
    markdown: {
      config(md) {
        md
          .use(require("markdown-it-footnote"))
          .use(require("markdown-it-deflist"))
        
      }
    },
    title: '光怪陆离前端',
    description: '我的前端笔记',
    head: [
        ['link', { rel: 'icon', href: `/favicons.ico` }],
    ],
    base: '/docs/',
    serviceWorker: true,
    // 别名配置
    configureWebpack: {
        resolve: {
            alias: {
                'src': './image'
            }
        }
    },
    themeConfig: {
        sidebarDepth: 2,            // 嵌套标题链接深度
        displayAllHeaders: false,    // 显示所有页面的标题链接
        activeHeaderLinks: true,    // 滚动激活的标题链接
        lastUpdated: 'Last Updated',// git 提交的 UNIX 时间戳
        serviceWorker: {
            updatePopup: true,
        },
        // 导航
        nav: [
            { text: '前端', link: '/fe/' },
            { text: '工具和库', link: '/tool/' },
            { text: '计算机通识', link: '/cs/' },
            { text: '读书笔记', link: '/note/' },
            { text: '职业规划', link: '/schedule/' },
            { text: 'BLOG', link: 'https://jjchu.github.io/' },
        ],
        // 多个侧边栏
        sidebar,
        // git 仓库
        // repo: 'https://gitee.com/Schoilar/mydocs',
        // repoLabel: '查看源码',
        // docsRepo: 'mydocs/docs',
        // docsDir: 'docs',
        // docsBranch: 'master',
        // editLinks: true,
        // editLinkText: '帮助我们改进页面内容！',

        lastUpdated: '最新更新于'

    },
}